var a = require("../../../component/WxNotificationCenter/WxNotificationCenter.js"), e = getApp();

Page({
    data: {
        weddingOrderId: "",
        shareAccessToken: "",
        hadLogin: !1,
        data: {},
        success: !1
    },
    priceAddCancel: function(a) {
        this.prompt.hideDialog();
    },
    priceAddOk: function(a) {
        this.prompt.hideDialog();
        var e = a.detail;
        this.qianDan(!0, e.marketPrice, e.cooperatePrice);
    },
    clickQian: function() {
        0 == this.data.hadLogin ? this.clickLogin() : 1 == this.data.workType ? e.util.showToast("请先上传图片作品") : 2 == this.data.data.workType ? e.util.showToast("请先上传视频作品") : 3 == this.data.data.workType ? e.util.showToast("请先上传图文作品") : this.qianDan();
    },
    clickLogin: function() {
        wx.navigateTo({
            url: "/pages/login/quickLogin/quickLogin"
        });
    },
    clickMore: function() {
        wx.reLaunch({
            url: "/pages/schedule/schedule?tab=1"
        });
    },
    clickUpload: function() {
        var a = this.data.data.workType;
        1 == a ? wx.navigateTo({
            url: "/pages/add/addImage/addImage"
        }) : 2 == a ? wx.navigateTo({
            url: "/pages/add/addVideo/addVideo"
        }) : 3 == a && wx.navigateTo({
            url: "/pages/add/addTuwen/addTuwen"
        });
    },
    loadData: function() {
        var a = this;
        e.network.post({
            url: e.url.WeddingOrderQiangDanDetail,
            params: {
                weddingOrderId: a.data.weddingOrderId
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(t) {
                if (1 == t.data.result) {
                    var i = t.data.data;
                    0 == i.workType ? i.workText = "" : 1 == i.workType ? i.workText = "点击上传图片作品" : 2 == i.workType ? i.workText = "点击上传视频作品" : 3 == i.workType && (i.workText = "点击上传图文作品"), 
                    a.setData({
                        data: i
                    });
                } else e.util.showToast(t.data.message);
            },
            fail: function() {
                e.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading();
            }
        });
    },
    qianDan: function(a, t, i) {
        var o, n = this;
        o = 1 == a ? {
            marketPrice: t,
            cooperationPrice: i,
            weddingOrderId: n.data.weddingOrderId,
            shareAccessToken: n.data.shareAccessToken
        } : {
            weddingOrderId: n.data.weddingOrderId,
            shareAccessToken: n.data.shareAccessToken
        }, e.network.post({
            url: e.url.QiangDanWeddingOrder,
            params: o,
            before: function() {
                wx.showLoading({
                    title: "正在抢单"
                });
            },
            success: function(a) {
                wx.hideLoading();
                a.data.result;
                1 == a.data.result ? (n.setData({
                    success: !0
                }), 1 == a.data.data.openAutoQiangDan ? wx.showModal({
                    title: "抢单成功",
                    content: "您的资料已提交给对应发单人，对方如有合作意向，将主动与您联系，请您留意。建议开启自动抢单，抢单快人一步",
                    confirmText: "自动抢单",
                    success: function(a) {
                        a.confirm && wx.navigateTo({
                            url: "/pages/sendOrder/orderSetting/orderSetting"
                        });
                    }
                }) : wx.showModal({
                    title: "抢单成功",
                    content: "您的资料已提交给对应发单人，对方如有合作意向，将主动与您联系，请您留意。",
                    showCancel: !1
                })) : 2 == a.data.result ? wx.showModal({
                    title: "提示",
                    content: a.data.message,
                    showCancel: !1
                }) : 3 == a.data.result ? (n.prompt = n.selectComponent("#addPriceDialog"), n.prompt.showDialog(a.data.data.marketPrice, a.data.data.cooperationPrice)) : e.util.showToast(a.data.message);
            },
            fail: function() {
                wx.hideLoading(), e.util.showToast("获取数据失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading();
            }
        });
    },
    didLoginSuccess: function() {
        this.loadData(), this.setData({
            hadLogin: e.util.isLogin()
        });
    },
    onLoad: function(t) {
        this.setData({
            weddingOrderId: t.weddingOrderId,
            shareAccessToken: t.shareAccessToken
        }), e.util.openSharePage(t);
        var i = this;
        a.addNotification("didLoginSuccess", i.didLoginSuccess, i), e.globalData.weddingOrderId = t.weddingOrderId;
    },
    onReady: function() {},
    onShow: function() {
        this.loadData(), this.setData({
            hadLogin: e.util.isLogin()
        });
    },
    onHide: function() {},
    onUnload: function() {
        e.globalData.weddingOrderId = "";
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});